Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD

Class com.pacist.diamonds.Controller

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Canvas
              |
              +--com.pacist.diamonds.DiamondCanvas
                    |
                    +--com.pacist.diamonds.Controller
Subclasses:
AngularController, LinearController

public class Controller
extends DiamondCanvas
Base class for controllers, knobs and progress bars etc. This class cannot be used alone. Use one of its sub-classes instead.

See Also:
Serialized Form

Field Summary
boolean canMeasure
           
java.util.Vector listeners
           
int maxValue
           
int minValue
           
boolean postOnMouseDown
           
boolean postWhileDragging
           
boolean showValue
           
int value
           
 
Fields inherited from class com.pacist.diamonds.DiamondCanvas
tipText
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Constructor Summary
Controller()
          Creates and initializes a new Controller object.
Controller(int min, int max, int initial)
          Creates and initializes a new Controller object with the specified minimum, maximum, and initial values.
 
Method Summary
void addControllerListener(ControllerListener l)
          Adds the specified Controller listener to receive Controller events from this Controller.
int getMaxValue()
          Gets the maximum value of the controller.
int getMinValue()
          Gets the minimum value of the controller.
boolean getPostOnMouseDown()
          Determines whether an event will be posted when the mouse is pressed down.
boolean getShowValue()
          Gets the show value of the controller.
int getValue()
          Gets the value of the controller.
java.lang.String getValueString(int v)
          Gets the value of the controller as a string.
boolean isMaxAtBottom()
          Determines whether the maximum is set to be at the bottom or not.
boolean mouseDragged(java.awt.event.MouseEvent event, int x, int y)
          Method called when the mouse has been dragged.
boolean mousePressed(java.awt.event.MouseEvent event, int x, int y)
          Method called when the mouse has been pressed.
boolean mouseReleased(java.awt.event.MouseEvent event, int x, int y)
          Method called when the mouse has been released.
void notifyValueChange()
          Notify all Controller listeners that there has been a value change.
int pinValue(int x)
          Given a value x, will return minValue >= x =< maxValue.
int pointToValue(int x, int y)
          Calculates the value from a point.
void processMouseEvent(java.awt.event.MouseEvent e)
          Processes mouse events occurring on this component by dispatching them to any registered MouseListener objects.
void processMouseMotionEvent(java.awt.event.MouseEvent e)
          Processes mouse motion events occurring on this component by dispatching them to any registered MouseMotionListener objects.
void removeControllerListener(ControllerListener l)
          Removes the specified Controller listener so that it no longer receives ControllerEvents from this Controller.
void setMaxAtBottom(boolean b)
          Sets the maximum to appear at the bottom.
void setMaxValue(int val)
          Sets the maximum value of the controller, and then repaints.
void setMinValue(int val)
          Sets the minimum value of the controller, and then repaints.
void setPostOnMouseDown(boolean b)
          Sets the controller to post an event when the mouse is pressed down.
void setShowValue(boolean val)
          Sets the show value of the controller, and then repaints.
void setValue(int v)
          Sets the value of the controller, causing it to be redrawn.
 
Methods inherited from class com.pacist.diamonds.DiamondCanvas
getTipText, mouseEnter, mouseExit, processMouseEvent, setTipText
 
Methods inherited from class java.awt.Canvas
addNotify, paint
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getName, getParent, getPeer, getPreferredSize, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paint, paramString, postEvent, preferredSize, prepareImage, prepareImage, printAll, print, processComponentEvent, processEvent, processFocusEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFont, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, update, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notifyAll, notify, toString, wait, wait, wait
 

Field Detail

minValue

protected int minValue

maxValue

protected int maxValue

value

protected int value

listeners

protected java.util.Vector listeners

showValue

protected boolean showValue

canMeasure

protected boolean canMeasure

postWhileDragging

protected boolean postWhileDragging

postOnMouseDown

protected boolean postOnMouseDown
Constructor Detail

Controller

public Controller()
Creates and initializes a new Controller object.
See Also:
Controller(int, int, int)

Controller

public Controller(int min,
                  int max,
                  int initial)
Creates and initializes a new Controller object with the specified minimum, maximum, and initial values.
Parameters:
min - the minimum value of the controller.
max - the maximum value of the controller.
initial - the initial value of the controller.
See Also:
Controller()
Method Detail

setValue

public void setValue(int v)
Sets the value of the controller, causing it to be redrawn. The value will be pinned to be between the minimum and maximum values.
Parameters:
v - the new value.

getValue

public int getValue()
Gets the value of the controller.
Returns:
the controller's value

setMaxAtBottom

public void setMaxAtBottom(boolean b)
Sets the maximum to appear at the bottom.

isMaxAtBottom

public boolean isMaxAtBottom()
Determines whether the maximum is set to be at the bottom or not.
Returns:
true if the maximum is set to be at the bottom; false otherwise.

getValueString

public java.lang.String getValueString(int v)
Gets the value of the controller as a string. Used for displaying the value. This may be overridden to display other values such as "slow", "fast" etc.
Returns:
the controller's value

setMinValue

public void setMinValue(int val)
Sets the minimum value of the controller, and then repaints.
Parameters:
val - the new minimum value.

getMinValue

public int getMinValue()
Gets the minimum value of the controller.
Returns:
the minimum value of the controller.

setMaxValue

public void setMaxValue(int val)
Sets the maximum value of the controller, and then repaints.
Parameters:
val - the new maximum value.

getMaxValue

public int getMaxValue()
Gets the maximum value of the controller.
Returns:
the maximum value of the controller.

getShowValue

public boolean getShowValue()
Gets the show value of the controller.
Returns:
the show value of the controller.

setShowValue

public void setShowValue(boolean val)
Sets the show value of the controller, and then repaints.
Parameters:
val - the new show value.

setPostOnMouseDown

public void setPostOnMouseDown(boolean b)
Sets the controller to post an event when the mouse is pressed down.
Parameters:
b - true - an event will be posted; false otherwise.
See Also:
getPostOnMouseDown()

getPostOnMouseDown

public boolean getPostOnMouseDown()
Determines whether an event will be posted when the mouse is pressed down.
Returns:
true if an event will be posted; false otherwise.
See Also:
setPostOnMouseDown(boolean)

addControllerListener

public void addControllerListener(ControllerListener l)
Adds the specified Controller listener to receive Controller events from this Controller. Controller events occur when a user drags the mouse, or presses or releases a mouse button.

removeControllerListener

public void removeControllerListener(ControllerListener l)
Removes the specified Controller listener so that it no longer receives ControllerEvents from this Controller.

pointToValue

protected int pointToValue(int x,
                           int y)
Calculates the value from a point.
Parameters:
x - the x coordinate.
y - the y coordinate.
Returns:
the value derived from the x and y coordinates.

pinValue

protected int pinValue(int x)
Given a value x, will return minValue >= x =< maxValue.

processMouseEvent

protected void processMouseEvent(java.awt.event.MouseEvent e)
Processes mouse events occurring on this component by dispatching them to any registered MouseListener objects.

This method is not called unless mouse events are enabled for this component. Mouse events are enabled when one of the following occurs:

Parameters:
e - the mouse event.
Overrides:
processMouseEvent in class DiamondCanvas
See Also:
java.awt.event.MouseEvent, java.awt.event.MouseListener, addMouseListener, enableEvents

processMouseMotionEvent

protected void processMouseMotionEvent(java.awt.event.MouseEvent e)
Processes mouse motion events occurring on this component by dispatching them to any registered MouseMotionListener objects.

This method is not called unless mouse motion events are enabled for this component. Mouse motion events are enabled when one of the following occurs:

Parameters:
e - the mouse motion event.
Overrides:
processMouseMotionEvent in class java.awt.Component
See Also:
java.awt.event.MouseMotionEvent, java.awt.event.MouseMotionListener, addMouseMotionListener, enableEvents

mousePressed

public boolean mousePressed(java.awt.event.MouseEvent event,
                            int x,
                            int y)
Method called when the mouse has been pressed.
Parameters:
event - the mouse event.
x - the x coordinate.
y - the y coordinate.
See Also:
java.awt.event.MouseEvent, java.awt.event.MouseListener

mouseDragged

public boolean mouseDragged(java.awt.event.MouseEvent event,
                            int x,
                            int y)
Method called when the mouse has been dragged.
Parameters:
event - the mouse event.
x - the x coordinate.
y - the y coordinate.
See Also:
java.awt.event.MouseEvent, java.awt.event.MouseListener

mouseReleased

public boolean mouseReleased(java.awt.event.MouseEvent event,
                             int x,
                             int y)
Method called when the mouse has been released.
Parameters:
event - the mouse event.
x - the x coordinate.
y - the y coordinate.
See Also:
java.awt.event.MouseEvent, java.awt.event.MouseListener

notifyValueChange

protected void notifyValueChange()
Notify all Controller listeners that there has been a value change.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD